package com.turtle3d.visualizator;

import javax.media.j3d.GeometryArray;
import javax.media.j3d.LineArray;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;

public class Line3D {

	private LineArray lineArray;

	public Line3D(Point3f p1, Point3f p2, Color3f color) {
		lineArray = new LineArray(2, GeometryArray.COORDINATES
				| GeometryArray.COLOR_3);
		lineArray.setCoordinate(0, p1);
		lineArray.setColor(0, color);
		lineArray.setCoordinate(1, p2);
		lineArray.setColor(1, color);
	}
	
	public Line3D(Vector3f p1, Vector3f p2, Color3f color) {
		lineArray = new LineArray(2, GeometryArray.COORDINATES
				| GeometryArray.COLOR_3);
		lineArray.setCoordinate(0, new Point3f(p1));
		lineArray.setColor(0, color);
		lineArray.setCoordinate(1, new Point3f(p2));
		lineArray.setColor(1, color);
	}
	
	
	public static Line3D test(){
		return new Line3D(new Point3f(0,0,0), new Point3f(0,2,0), new Color3f(1,1,1));
	}

	public Shape3D toShape3D() {
		return new Shape3D(lineArray);
	}
}
